Skip to content

refactor(compute): make sandbox readiness gateway-owned across all drivers - #2153

Merged
elezar merged 4 commits into
mainfrom
refactor/1951-gateway-owned-sandbox-readiness/elezar
Jul 29, 2026
Merged

refactor(compute): make sandbox readiness gateway-owned across all drivers#2153
elezar merged 4 commits into
mainfrom
refactor/1951-gateway-owned-sandbox-readiness/elezar

Conversation

@elezar

@elezar elezar commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Centralizes the public SandboxPhase::Ready decision in the gateway. Compute drivers report backend state only; the gateway composes that state with supervisor session presence to produce the public phase. A structural refactor extracts the dispatch helpers first so the behavioral change remains isolated and reviewable.

A sandbox is Ready only while its supervisor control session is connected to the gateway. A backend-ready sandbox without that session remains Provisioning and reports Ready=False with reason SupervisorNotConnected.

Related Issue

Closes #1951

HA supervisor-session ownership and routing remain deferred to #1868.

Changes

  • crates/openshell-server/src/compute/mod.rs: Extract create_sandbox_record and update_sandbox_record from apply_sandbox_update_locked; add ComposedPhase for gateway-owned readiness composition; promote on supervisor connect and demote on disconnect; expose SupervisorNotConnected when the backend is ready without a session.
  • crates/openshell-driver-docker/src/lib.rs: Remove the gateway session registry dependency from the Docker driver and report backend readiness only.
  • crates/openshell-driver-docker/src/tests.rs: Update driver assertions to use backend readiness semantics.
  • crates/openshell-server/src/supervisor_session.rs: Remove the obsolete SupervisorReadiness implementation and route session lifecycle changes through the compute runtime.
  • architecture/compute-runtimes.md: Document the gateway readiness composition contract, lifecycle precedence, HA limitation, and compute-driver extension boundary.
  • docs/sandboxes/manage-sandboxes.mdx: Document the user-visible Provisioning, Ready=False, and SupervisorNotConnected behavior, including temporary reprovisioning while a supervisor reconnects after a gateway restart.

Deviations from Plan

The PR does not infer cross-replica supervisor presence from a previously stored Ready phase. Correct HA session ownership, liveness, and request routing require a separately persisted or leased presence signal and remain part of #1868.

Testing

  • mise run docs (0 errors; Fern reports 2 warnings only when requested with --warnings)
  • Markdown, Mermaid, Python format/lint, license, Helm lint/docs, and Rust format checks completed successfully as part of mise run pre-commit
  • Unit coverage updated for readiness composition, backend-ready-without-session, and supervisor disconnect behavior
  • Full mise run pre-commit is currently blocked by an unused Ordering import in the untouched crates/openshell-sandbox/src/lib.rs:20
  • E2E not run locally; GitHub Actions provides the sandbox runtime matrix

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture documentation updated
  • User-facing documentation updated

@elezar
elezar requested review from a team, derekwaynecarr, maxamillion and mrunalp as code owners July 6, 2026 17:28
@elezar elezar added test:e2e Requires end-to-end coverage test:e2e-kubernetes Requires Kubernetes end-to-end coverage labels Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Label test:e2e-kubernetes applied for 84c2c32. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute Kubernetes HA E2E after building the required gateway and supervisor images once. This is an optional proof-of-life suite; failures are visible in the workflow run but do not publish a required CI gate status.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Label test:e2e applied for 84c2c32. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute the standard E2E suite after building the required gateway and supervisor images once. The matching required CI gate status on this PR will flip green automatically once the run finishes.

Comment thread architecture/compute-runtimes.md
@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch 2 times, most recently from 0767cc7 to 6ea68c6 Compare July 7, 2026 08:46
@elezar elezar removed the test:e2e-kubernetes Requires Kubernetes end-to-end coverage label Jul 17, 2026
@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch 2 times, most recently from 761589e to 0c65b0e Compare July 21, 2026 16:20
@elezar elezar added the gator:blocked Gator is blocked by process or repository gates label Jul 22, 2026
@elezar

elezar commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

gator-agent

Blocked

Head SHA: 0c65b0e52e4ccf32a982eff52044d2bd09f7fad8

Gator is blocked because GitHub reports this PR as DIRTY, which indicates the branch cannot currently be merged cleanly into main.

Next action: @elezar, please update the PR branch to resolve the merge conflict. Gator will re-check the PR after the branch is mergeable again.

@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch from 0c65b0e to fc29302 Compare July 24, 2026 15:11
@drew drew self-assigned this Jul 25, 2026

@elezar elezar left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Validation: PR #2153 is project-valid because it implements the linked, already-scoped readiness issue #1951 and keeps the changes concentrated in compute runtime readiness behavior and documentation.
Head SHA: 38b20f26d0c0cbfe0f4f16f14248afd3b49bbfe5

Review findings:

  • One warning remains about HA readiness composition when the reconciling replica is not the supervisor-session owner.

Docs: Architecture docs were updated in architecture/compute-runtimes.md; no Fern docs change is required for this internal runtime contract until the user-facing lifecycle text changes.

I incorporated @elezar's note that a supervisor connection can arrive before backend Ready and implies the workload is running; that explains the session-precedence arm, but the HA demotion path below still needs attention.

Next state: gator:in-review

Comment thread crates/openshell-server/src/compute/mod.rs
@elezar elezar added gator:in-review Gator is reviewing or awaiting PR review feedback and removed gator:blocked Gator is blocked by process or repository gates labels Jul 26, 2026
@drew drew removed their assignment Jul 27, 2026
drew
drew previously approved these changes Jul 27, 2026
…ecord helpers

Split apply_sandbox_update_locked into named helpers to make the two
distinct paths explicit: create_sandbox_record for first-observation events
and update_sandbox_record for subsequent driver snapshots on existing sandboxes.
The dispatcher now uses a match on the existing record rather than an
early-return guard.

No behavior change.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch from 7bbb126 to 4c596c7 Compare July 28, 2026 08:28
@elezar
elezar enabled auto-merge July 28, 2026 14:35

@elezar elezar left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Validation: PR #2153 is project-valid because it implements linked issue #1951's already-scoped gateway-owned sandbox readiness refactor, with changes concentrated in compute readiness, Docker driver reporting, tests, and architecture docs.
Head SHA: 4c596c7cc6544f4e694ff7a7f84efe33e78493bd

Review findings:

  • Warning: HA readiness composition still treats the previous public Ready phase as enough evidence of a recorded supervisor session. After a gateway restart or owner crash, the store can still say Ready while the current process has no supervisor session.
  • Warning: Fern docs are missing for the user-visible lifecycle behavior where a backend-ready sandbox without a supervisor session remains Provisioning with Ready=False, SupervisorNotConnected.

Docs: architecture/compute-runtimes.md was updated, but docs/ still needs a user-facing update because this changes CLI/API-visible sandbox phase interpretation.

I incorporated @elezar's note that the HA point was discussed with @drew and checked the latest fix(compute): preserve HA readiness across replicas commit. The current implementation preserves readiness for a non-owner replica, but the remaining restart/owner-loss case below still needs attention.

Next state: gator:in-review

Comment thread crates/openshell-server/src/compute/mod.rs Outdated
@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch from 4c596c7 to 2697949 Compare July 28, 2026 15:44
@github-actions

Copy link
Copy Markdown

@elezar elezar left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Validation: PR #2153 is project-valid because it implements linked issue #1951's already-scoped gateway-owned sandbox readiness refactor, with changes concentrated in compute readiness, Docker driver reporting, tests, and architecture/user docs.
Head SHA: 2697949683dd461145b56eb932a3d72ad395fe23

Review findings:

  • Warning: the HA section still describes the current process-local session behavior as correct even though @elezar noted the HA implementation is intentionally deferred to #1868. The docs should call this a known limitation, or the implementation needs persisted/leased supervisor presence.
  • Suggestion: the new Docker-specific default supervisor image helper duplicates the existing core config source of truth and should either be removed or wired in intentionally.

Docs: docs/sandboxes/manage-sandboxes.mdx now covers the user-visible SupervisorNotConnected lifecycle behavior, and the page is already present in Fern navigation. The architecture HA wording still needs the clarification above.

I incorporated @elezar's note that the HA implementation was discussed and deferred to #1868; I checked the latest code and docs against that deferred scope rather than requiring the HA lease implementation in this PR.

Next state: gator:in-review

Comment thread architecture/compute-runtimes.md Outdated
Comment thread crates/openshell-driver-docker/src/lib.rs Outdated
elezar and others added 3 commits July 28, 2026 20:20
…ivers

Introduce compute_phase_components and apply_readiness_conditions to
centralise the gateway's phase composition logic. The public SandboxPhase
is now determined by combining the backend phase reported by the driver with
supervisor session presence, independent of the driver implementation.

Remove SupervisorReadiness from the driver contract. Running containers
always report BackendReady; the gateway owns the Ready decision. Rename
the dispatcher match to three arms so that status-less events for existing
sandboxes are a documented no-op rather than a silent pass-through.

Drop backend_ready_no_session and the SupervisorNotConnected condition.
The BackendReady driver condition plus the Provisioning phase already
communicates that the backend is up but the supervisor has not connected.
The redundant condition added noise without new information.

Closes #1951

Signed-off-by: Evan Lezar <elezar@nvidia.com>
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
Signed-off-by: Evan Lezar <elezar@nvidia.com>
@elezar
elezar force-pushed the refactor/1951-gateway-owned-sandbox-readiness/elezar branch from 2697949 to 74396b8 Compare July 28, 2026 20:07

@elezar elezar left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

Maintainer Approval Needed

Head SHA: 74396b84e087a449250e198bfd6e4cdf723927f4

Validation: PR #2153 is project-valid because it implements linked issue #1951 and keeps the readiness refactor concentrated in gateway compute composition, Docker backend reporting, tests, and architecture/user docs.

Review: The required independent principal-engineer review found no blocking findings for this head. Previous gator feedback is resolved: @elezar clarified that HA supervisor ownership is deferred after discussion with @drew, the architecture doc now documents that known HA limitation and links it to #1868, the Fern sandbox lifecycle docs cover SupervisorNotConnected, and the Docker default supervisor image source of truth is no longer duplicated.

Docs: architecture/compute-runtimes.md and docs/sandboxes/manage-sandboxes.mdx are updated. No Fern navigation change is needed because the user-facing lifecycle text is on an existing docs page.

Checks: Required Branch Checks, Helm Lint, DCO, Rust, Python, Markdown, license, and preview checks are green for this head.

E2E: test:e2e is applied and OpenShell / E2E is green. GPU E2E is not required because test:e2e-gpu is not applied.

Human maintainer approval is now required.

@elezar elezar added gator:approval-needed Gator completed review; maintainer approval needed and removed gator:in-review Gator is reviewing or awaiting PR review feedback labels Jul 29, 2026
@elezar
elezar requested a review from drew July 29, 2026 10:05
@elezar
elezar added this pull request to the merge queue Jul 29, 2026
@elezar elezar added gator:merge-ready and removed gator:approval-needed Gator completed review; maintainer approval needed labels Jul 29, 2026
Merged via the queue into main with commit 662dee6 Jul 29, 2026
56 of 58 checks passed
@elezar
elezar deleted the refactor/1951-gateway-owned-sandbox-readiness/elezar branch July 29, 2026 10:21
@elezar

elezar commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

gator-agent

Monitoring Complete

Monitoring is complete because this PR has merged.

Final status: PR #2153 reached gator:merge-ready on head 74396b84e087a449250e198bfd6e4cdf723927f4 after gator review completed, required checks including E2E were green, and maintainer approval was present. It was merged on 2026-07-29 at 10:20:58Z.

I removed the active gator:* label because there is nothing left for gator to monitor on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: make sandbox readiness gateway-owned across compute drivers

3 participants